/******************************************************************
Copyright © LibKz 2017~2023. All rights reserved.
* @projectName   LibKz
* @author        Raiiwhen
* @email         masterraii@icloud.com
*******************************************************************/
#include "../common_typedef.h"

typedef void (*stdIO)(uint8_t isSet);
typedef void (*stdSetVal)(float val); // val∈[0.0f, 1.0f]
typedef enum
{
    IO_HUMAN_LED_BREATH,
    IO_HUMAN_LED_BLINK, // blink once
    IO_HUMAN_LED_FLASH, // flash multiple times
} ioHumanLedState;
typedef struct 
{
    stdIO ctrlHandle;
    stdSetVal ctrlSetBrightness;
    // private
    int exeFreq; // in Hz, 100Hz suggested
    int timePeriod; // in ms, Animation Period, 1000ms by default
    int timeCnt; // in ms, Animation progess
    int timeStep; // in ms
    ioHumanLedState idleState;
    ioHumanLedState state;
} ioHumanLed;

void IoHumanLedInit(ioHumanLed* led, stdIO ctrlHandle, ioHumanLedState defaultState);
void IoHumanLedConfigPWM(ioHumanLed* led, stdSetVal ctrlSetBrightness);
void IoHumanLedExe(ioHumanLed* led);

void IoHumanLedConfigFreq(ioHumanLed* led, int exeFreq);
void IoHumanLedPushEvent(ioHumanLedState idleState);